a=-0.707;
b=0.9;
c=3.0;

t=-pi:pi/10:1.3*pi;
t=t';
temp = t.+b;
y=a+c*sin(temp);
m=(y>0);
y=y.*m;

x=[1:rows(t)]';
x1=cos(t);
x2=sin(t);
X(:,1)=ones(1,rows(x));
X(:,2)=x1;
X(:,3)=x2;
a=inv(X'*X)*(X'*y);
A=a(1,1);
disp(a(2,1)/a(3,1));
B=atan(a(2,1)/a(3,1));
C=sqrt(a(2,1)^2 + a(3,1)^2);
for i=1:rows(y)
	yc(i,1)=A+C*sin(t(i,1)+B);
endfor

disp(A);
disp(B);
disp(C);

figure;
subplot(2,1,1);
bar(t,y);
hold on;
plot(t,yc,"-m");

x=x.-1;
x1=cos(x);
x2=sin(x);
X(:,1)=ones(1,rows(x));
X(:,2)=x1;
X(:,3)=x2;
a=inv(X'*X)*(X'*y);
A=a(1,1);
disp(a(2,1)/a(3,1));
B=atan(a(2,1)/a(3,1));
C=sqrt(a(2,1)^2 + a(3,1)^2);
for i=1:rows(y)
	yc(i,1)=A+C*sin(x(i,1)+B);
endfor

disp(A);
disp(B);
disp(C);

subplot(2,1,2);
bar(x,yc);
